package com.whlilong.jxc.info;

import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import com.whlilong.jxc.constants.IAppConstants;
import com.whlilong.jxc.sys.CacheImage;
import com.whlilong.jxc.sys.IImageKey;

public class KeshangInfoDialog extends TitleAreaDialog {

	private String info ;
	
	private boolean tag;
	
	public KeshangInfoDialog(Shell parentShell, String info) {
		super(parentShell);
		super.setShellStyle(getShellStyle() & ~SWT.APPLICATION_MODAL // 消除模式
				| SWT.ON_TOP | SWT.RESIZE);// 处于顶层
		this.info = info;
		
		// TODO Auto-generated constructor stub
	}
	
	protected Control createDialogArea(Composite parent) {
		// create the top level composite for the dialog area
		Shell shell = this.getShell();
		shell.setText(info);
		this.setTitle(info);
		this.setMessage("\n查看,修改,添加,删除"+ info + ".", IMessageProvider.INFORMATION);// 显示提示小图标
		this.setTitleImage(CacheImage.getINSTANCE().getImage(
				IAppConstants.APPLICATION_ID, IImageKey.ks));
		
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout layout = new GridLayout();
		layout.marginHeight = 0;
		layout.marginWidth = 0;
		layout.verticalSpacing = 0;
		layout.horizontalSpacing = 0;
		composite.setLayout(layout);
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
		composite.setFont(parent.getFont());
		
		// Build the separator line
		Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL
				| SWT.SEPARATOR);
		titleBarSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		return composite;
	}

	protected Point getInitialSize() {
		Point shellSize = super.getInitialSize();
		Rectangle screenSize = Display.getDefault().getClientArea();
		return new Point(screenSize.width - 20, screenSize.height - 80);
	}

	protected Point getInitialLocation(Point initialSize) {
		Point result = new Point(10, 60);

		return result;
	}

}
